package com.example.hhh.controller;

import com.example.hhh.model.OrderNote;
import com.example.hhh.service.OrderNoteService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/order-notes")
public class OrderNoteController {

    private final OrderNoteService orderNoteService;

    public OrderNoteController(OrderNoteService orderNoteService) {
        this.orderNoteService = orderNoteService;
    }

    @PostMapping
    public ResponseEntity<OrderNote> createNote(@RequestBody OrderNote note) {
        return ResponseEntity.ok(orderNoteService.createNote(note));
    }

    @GetMapping("/by-order/{orderId}")
    public ResponseEntity<List<OrderNote>> getNotesByOrder(
            @PathVariable Integer orderId) {
        return ResponseEntity.ok(
                orderNoteService.getNotesByOrder(orderId));
    }
}